package com.hf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hf.entity.Customer;
import com.hf.mapper.CustomerMapper;
import com.hf.service.ICustomerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author eight
 * @since 2021-06-06
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService {
	@Autowired
	CustomerMapper cusMapper;

	@Override
	public IPage<Customer> queryCustomers(String cusName, Integer page, Integer limit) {
		Page<Customer> p = new Page<>(page, limit);
		QueryWrapper<Customer> queryWrapper = new QueryWrapper<Customer>();

		if (cusName != null && !cusName.equals("")) {
			queryWrapper.like("cus_name", cusName);
		}
		queryWrapper.orderByDesc("id");
		return cusMapper.selectPage(p, queryWrapper);
	}

}
